using System;
using UnityEngine;
using Unity.VisualScripting;
using GameFramework.Event;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Open UI Form")]
    [UnitSurtitle("Success")]
    public sealed class OpenUIFormUpdate : FrameworkEventUnit<OpenUIFormUpdateEventArgs>
    {
        protected override int EventId => OpenUIFormUpdateEventArgs.EventId;
        protected override string HookName => UGFHookNames.OpenUIFormUpdate;

        [DoNotSerialize] 
        [PortLabelHidden] 
        public ValueOutput SerialId { get; private set; }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UIFormAssetName { get; private set; }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UIGroupName { get; private set; }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput PauseCoveredUIForm { get; private set; }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Progress { get; private set; }

        [DoNotSerialize] 
        [PortLabelHidden] 
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            SerialId = ValueOutput<int>(nameof(SerialId));
            UIFormAssetName = ValueOutput<string>(nameof(UIFormAssetName));
            UIGroupName = ValueOutput<string>(nameof(UIGroupName));
            PauseCoveredUIForm = ValueOutput<bool>(nameof(PauseCoveredUIForm));
            Progress = ValueOutput<float>(nameof(Progress));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, OpenUIFormUpdateEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(SerialId, args.SerialId);
            flow.SetValue(UIFormAssetName, args.UIFormAssetName);
            flow.SetValue(UIGroupName, args.UIGroupName);
            flow.SetValue(PauseCoveredUIForm, args.PauseCoveredUIForm);
            flow.SetValue(Progress, args.Progress);
            flow.SetValue(UserData, args.UserData);
        }
    }
}